Use: SELECT a. *, x. Num FROM TABLE_A a JOIN (SELECT t.Id, COUNT(*) AS num FROM TABLE_B t WHERE t.
Timestamp BETWEEN DATE_SUB(NOW, INTERVAL 1 DAY) AND NOW() GROUP BY t. Id) x ON x.Id = a. Id ORDER BY x.
Num DESC.
Thanks for your response too! I'll try this one out too and get back to you. – RobHardgood Oct 18 '10 at 2:48 seems like you lost = a.Id in ON clause.
Did not you? – zerkms Oct 18 '10 at 3:01 @zerkms: Corrected, thx. – OMG Ponies Oct 18 '10 at 3:02.
Try: Select b. ColA, b. ColB, b.
ColC,-- etc. Count(*) count From TableB be Join TableA a On a. Id = b.Id And a. TimeStamp > getDate() - 1 Group By b.
ColA, b. ColB, b. ColC -- etc. Order By Count(*) Desc If you also want to see the rows from TableB that have no timestamps in the past 24 hours then use an outer join: Select b.
ColA, b. ColB, b. ColC,-- etc.Count(*) count From TableB be Left Join TableA a On a.
Id = b. Id And a. TimeStamp > getDate() - 1 Group By b.
ColA, b. ColB, b. ColC -- etc. Order By Count(*) Desc.
Thanks for your response! It's going to take me a while to try everything and figure out what it's doing, but I'll let you know if it works for me. Thanks again.
– RobHardgood Oct 18 '10 at 2:48.
I want to make some kind of join that will sort by the number of entries in the first table with a timestamp more recent than 24 hours. So basically, if there are 30 entries in the first table with a timestamp of less than 24 hours with the ID "334" then I want to select the row from the second table with the ID of 334. And that should come before an entry with the ID "234" that only has 20 entries within the last 24 hours.
I hope this is clear... I'm really stumped on how to do this, so thanks for any help.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.